package com.homedo.odin.solution.enumcode.basic;

import java.util.Arrays;
import lombok.Getter;

/**
 * 评价类型
 *
 * @author ZhangLei
 */
@Getter
public enum ColumnTypeEnum {

    SPECIAL_COLUMN(1, "专栏栏目"),
    VIDEO_COLUMN(2, "视频栏目"),
    SOLUTION(3, "方案"),
    SPECIFICATION(4, "规范");

    private Integer dbValue;
    private String displayValue;

    ColumnTypeEnum(Integer dbValue, String displayValue) {
        this.displayValue = displayValue;
        this.dbValue = dbValue;
    }

    /**
     * 判断是否存在枚举dbValue
     */
    public static boolean dbValueExist(Integer dbValue) {
        return Arrays.stream(ColumnTypeEnum.values()).anyMatch(obj -> obj.getDbValue().equals(dbValue));
    }

    /**
     * 判断是否存在枚举displayValue
     */
    public static boolean displayValueExist(String displayValue) {
        return Arrays.stream(ColumnTypeEnum.values()).anyMatch(obj -> obj.getDisplayValue().equals(displayValue));
    }

    /**
     * 匹配获取对应的DisplayValue
     */
    public static String getExistDisplayValue(Integer dbValue) {
        return Arrays.stream(ColumnTypeEnum.values()).filter(obj -> obj.getDbValue().equals(dbValue))
                .map(obj -> obj.getDisplayValue()).findFirst().orElse(null);
    }

}
